#ifndef BUTTERFLY_H
#define BUTTERFLY_H

#include <QObject>
#include <QGraphicsItem>
#include <QPainter>
#include <QGraphicsScene>
#include <QGraphicsView>

class Butterfly : public QObject, public QGraphicsItem
{
    Q_OBJECT
public:
    explicit Butterfly(QObject *parent = nullptr);

    void timerEvent(QTimerEvent *); // 继承QObject，StartTimer KillTimer TimerEvent
    QRectF boundingRect() const; // 限定graphicsitem的区域，纯虚，所有继承QGraphicsItem的自定义图元都必须实现

signals:

public slots:

protected:
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); // 继承QGraphicsItem，绘制函数

private:
    bool up; // 表示蝴蝶翅膀位于上or下
    QPixmap pix_up;            //用于表示两幅蝴蝶的图片
    QPixmap pix_down;

    qreal angle;
};

#endif // BUTTERFLY_H
